<template>
    <div>
        <el-form :model="form">
            <el-form-item label="名字" >
                <el-input v-model="form.name" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="价格" >
                <el-input v-model="form.price" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="库存" >
                <el-input v-model="form.repertory" autocomplete="off"></el-input>
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer" >
                <el-button @click="dialogadd= false">取 消</el-button>
                <el-button type="primary"  @click="todad()" :plain="true">确 定</el-button>
        </div>
    </div>
</template>

<script>
    export default {
        props:{
            dialogadd:{
                type:Boolean,
                default:true
            }
        },data(){
            return{
                form:{name:'',price:null,repertory:''}
            }
        },
        methods:{
            todad() {
                if(this.form.name=='' || this.form.price==''){
                    this.$message.error('名称，价格不可以为空');
                }
                else{     
                    if(this.form.repertory==''){
                        this.form.repertory='/'        
                    }       
                    this.$emit('update:dialogadd', false); // 推荐使用这种方式
                    this.$emit('senddad', this.form); // 发送表单数据
                    this.form={name:'',price:'',repertory:''}}
            }
        }
        
    }
</script>

<style>

</style>